home *** CD-ROM | disk | FTP | other *** search
- Path: cs.uwa.edu.au!jasonb
- From: jasonb@cs.uwa.edu.au (Jason S Birch)
- Newsgroups: comp.sys.amiga.programmer
- Subject: Re: PPC compilers
- Date: 15 Jan 96 02:49:26 GMT
- Organization: The University of Western Australia
- Message-ID: <jasonb.821674166@cs.uwa.edu.au>
- References: <john.hendrikx.40ka@grafix.xs4all.nl> <jasonb.820051107@cs.uwa.edu.au> <VBzVx*M3f@yaps.rhein.de> <4d0tf0$i4i@maureen.teleport.com> <jasonb.821371468@cs.uwa.edu.au> <4d5k6h$a2j@maureen.teleport.com>
- NNTP-Posting-Host: decadence.cs.uwa.oz.au
- X-Newsreader: NN version 6.5.0 #3 (NOV)
-
- sschaem@teleport.com (Stephan Schaem) writes:
-
- >Jason S Birch (jasonb@cs.uwa.edu.au) wrote:
- >: No, it wasn't, which is what I've been repeatedly saying. It was about
- >: whether assembler is easier to debug than C because the line:
-
- >: move.w (a0)+,(a1)+
-
- >: tells you how many bytes are being moved, and added to a0 and a1,
- >: whereas:
-
- > It tells me that I move a word from a0 to a1 and let point a0 and a1 to
- > the next word. (I just happen to know word is 2 byte:)
-
- Yes, but it *doesn't* tell you if you *wanted* to move a word from a0
- to a1. This is the whole point - you have to know what a0 and a1 are
- pointing to, and you have to know the *size* of the thing they are
- pointing to (ie. the implementation of the abstract data type) in
- order to know if that line is correct. Keep this in mind.
-
- >: *a++ = *b++;
-
- > Notice I didn't mention type size for asm or C... And where we not talking
- > about debuging already compiled code, right? I recall we where talking
- > about writting code.
-
- We were actually talking about trying to debug a program, and whether
- it was easier to debug C or asm because in asm you have more knowledge
- of what the machine is actually going to do. The idea was you have just
- that one line of code and want to know if it's correct or not. The
- answer is, in both cases, you can't tell. In C, you need to look at the
- variable declarations of a and b and do a simple check to see if they
- are the same type. This requires absolutely no knowledge of the
- behaviour of types under C - if a and b are the same type, that line
- *will* work - you then just need to check to see if that type is what
- you wanted. If they are not, then you need to know a bit about how the
- types are defined to establish if they are *equivalent*. In asm,
- however, you first have to work out where the current values of a0 and
- a1 came from, to make sure that's correct. Then you have to work out
- ^^^^^^^^^^^^^^^^^^^^^^^^^
- whether the type they're pointing to is actually a word. *Then* you
- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
- have to be sure it was *meant* to be a word. I've underlined the
- biggest difference.
-
- > I will repeat:
-
- > move.word (a0)+,(a1)+
-
- > I would not write the above if I didn't know a0 and a1 are of the same type.
-
- Unless you make a mistake. We were talking about debugging. If you
- never write lines of code without incorrectly "knowing" all the
- required information beforehand, I guess you never have bugs. Also,
- you have to know that a0 and a1 are *implemented* as words.
-
- > a++ = b++
-
- > I would not write the above if I didn't know a and b are of the same type,
- > or a type compatible with C operators, or a type that can be converted..
-
- Likewise, except you don't need to know how a and b are implemented (oh
- - I'm assuming you made one of those mistakes in the above and actually
- meant to write *a++ = *b++).
-
- > basicly in both case know the variable type, and type definition.
-
- Of course - it's just that the claim the asm one is easier to debug
- because it includes type information is bogus.
-
- >: This is a red herring. If the *type* of an element in a structure is
- >: given as ulong, then it must be a ulong, it is bound to being a ulong,
- >: and you can forever more treat it as a ulong. If it's given as a
- >: bilby, however, and somewhere else a bilby is defined to be a ulong
- >: (via typedef), then it is only bound to being a bilby and you can only
- >: treat it like a bilby - you may not treat it as a ulong.
-
- > Yes, and I read that clock_t was a ulong...
-
- This is why I said it was a red herring. If you have:
-
- struct SomeType {
- ulong a_field;
- ulong b_field;
- };
-
- Then you are quite legitimately able to treat a_field as a ulong. If,
- however, you have:
-
- typedef ulong field_t;
-
- struct SomeType {
- field_t a_field;
- field_t b_field;
- };
-
- Then you can only assume a_field is of type field_t, and *not* of type
- ulong. Similarly, if you have:
-
- typedef ulong clock_t;
-
- Then you can only create relevant variables of type clock_t (NOT
- ulong) and give those to functions expecting a variable of that type.
- The *reason* clock_t is created at all (and the support functions
- don't simply use ulong) is that they want it to be abstract. You must
- respect that.
-
- > Yes... I rely on ANSI standart of min range assigned ...
-
- What ANSI standard for min ranges???
-
- > I mentioned all that early on in my post. I also mentioned that I write
- > common code for windows & macos, So I would hope to know about making code
- > portable...
-
- Do you often use things like ulong when you mean clock_t? Also,
- AmigaOS, Windows, and MacOS aren't that different for standard ANSI
- code - only int changes in size.
-
- >: It couldn't, because "-" would no longer work; however, if a
- >: DiffClock() function existed, it could. time_t is a better example.
-
- > This is also true for asm...
-
- Except - and here's the kicker - if you wanted to do anything
- non-trivial, you need to know how big the implementation of a size is,
- like in the move.w (a0)+,(a1)+ example above. With C, if you know it's
- an ordinal type, for example (such as for clock_t), you can use all the
- arithmetic operators without having to worry about *which* ordinal type
- it's equivalent to.
-
- >: This is the problem - he never wanted to prove that. You misinterpreted
- >: his comments, and have thus far refused to give up your straw man. :-)
-
- > Ok then... its just that when I saw something, and one respond "no you
- > are wrong" + detail, I like to prove my original point. I fell strong
- > about it because this fact ahappen on everyline I write in ASM or C.
- > So someone telling me (Or me reading) that I dont have to bother with type
- > definition and even variable type after I define:declare them turn my
- > world around :)
-
- Well, it's not just your misunderstanding of the original comments,
- you keep giving the impression (as this post shows) that you think
- having to know if an assembler type is equivalent to a word is the
- same as knowing clock_t is a ulong, which is not the case at all.
-
- > Stephan
-
- --
- Jason S Birch ,-_|\ email: jasonb@cs.uwa.edu.au
- Department of Computer Science / \ Tel (work): +61 9 380 1840
- The University of Western Australia *_.-._/ Fax (work): +61 9 380 1089
- Nedlands W. Australia 6907 v Tel (home): +61 9 386 8630
-